package com.hqyj.springCloudWeb.controller;

import com.hqyj.entity.test.City;
import com.hqyj.util.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Controller
@RequestMapping("/test")
public class TestController {

    /**
     * 127.0.0.1/test/webSocketIndex ---- get
     */
    @GetMapping("/webSocketIndex")
    public String websocketIndexPage() {
        return "index";
    }

    /**
     * 127.0.0.1/test/vueIndex ---- get
     */
    @GetMapping("/vueIndex")
    public String vueIndexPage(){
        return "index";
    }


    /**
     * 127.0.0.1/test/thymeleafIndex  ---- get
     */
    @GetMapping("/thymeleafIndex")
    public String testIndexPage(ModelMap modelMap) {
//        int i = 10/0;
        City city = new City();
        List<City> cities = new ArrayList<>();

        modelMap.addAttribute("thymeleafTitle","我是一名中国人！");
        modelMap.addAttribute("checked",true);
        modelMap.addAttribute("currentNumber",23);
        modelMap.addAttribute("currentNumber", 99);
        modelMap.addAttribute("src", "/image/NiZhuanJieJu2.jpg");
        modelMap.addAttribute("href", "http://www.baidu.com");
        modelMap.addAttribute("city", city);
        modelMap.addAttribute("cities", cities);
//        modelMap.addAttribute("page","test/thymeleafIndex");
        return "index";
    }
}
